package top.xtcoder.jdcbase.base.knife4j;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

import org.springframework.web.bind.annotation.RestController;

import springfox.documentation.builders.PathSelectors;
import springfox.documentation.builders.RequestHandlerSelectors;
import springfox.documentation.spi.DocumentationType;
import springfox.documentation.spring.web.plugins.Docket;

@Configuration
public class Knife4jPBConfiguration {
    @Value("${knife4j.enable:false}")
    private boolean enable;
	@Autowired
	private Knife4jPBApiInfo apiInfo;
	@Autowired
	private Knife4jPBGlobalRequestParam global;

	@Bean(value = "defaultPrBaseApiAll")
    public Docket defaultPrBaseApiAll() {
        Docket docket=new Docket(DocumentationType.SWAGGER_2)
                .enable(enable)
                .apiInfo(apiInfo.apiInfo())
                .groupName("All")
                .select()
                .apis(RequestHandlerSelectors.withClassAnnotation(RestController.class))
                .paths(PathSelectors.any())
                .build()
                .globalOperationParameters(global.getGlobalRequestParameters());
        return docket;
    }
	
	@Bean(value = "defaultPrBaseUse")
    public Docket defaultPrBaseUse() {
        Docket docket = new Docket(DocumentationType.SWAGGER_2)
                .enable(enable)
                .apiInfo(apiInfo.apiInfo())
                .groupName("PB基础模块")
                .select()
                .apis(RequestHandlerSelectors.basePackage("top.xtcoder.jdcbase.base.controller"))
                .paths(PathSelectors.any())
                .build()
                .globalOperationParameters(global.getGlobalRequestParameters());
        return docket;
    }
}
